#ifndef HISTORYPRODUCT_H
#define HISTORYPRODUCT_H

#include <QObject>
#include "company.h"
#include "product.h"

class HistoryProduct : public QObject
{
    Q_OBJECT
public:
    explicit HistoryProduct(QObject *parent = nullptr);

    int id;
    int type;
    QString sourceCompanyId;
    QString targetCompanyId;
    QString sourceProductId;
    QString targetProductId;
    int sourceScale;
    int targetScale;
    double historyPrice;

    Company targetCompany;

    void loadFromJsonObject(QJsonObject obj);

    Product* getProduct();

    QString toJson();

    static QString toJson(QList<HistoryProduct*> historyProducts){
        QString jsonStr = "[";

        for(HistoryProduct *historyProduct:historyProducts){
            jsonStr.append(historyProduct->toJson()+",");
        }

        jsonStr.append("]");

        return jsonStr;
    }
signals:

public slots:

private:
    Product *product;
};

#endif // HISTORYPRODUCT_H
